from numba import jit
import numpy as np
import time

size=2000
x=np.random.random((size,size))

def normal_tan_sum(mat):
    tan_sum=0
    for i in range(size):
        for j in range(size):
            tan_sum+=np.tanh(mat[i,j])
    return tan_sum

@jit(nopython=True)
def faster_tan_sum(mat):
    tan_sum = 0
    for i in range(size):
        for j in range(size):
            tan_sum += np.tanh(mat[i, j])
    return tan_sum

start=time.time()
print(normal_tan_sum(x))
mid=time.time()
print(faster_tan_sum(x))
end=time.time()
print(mid-start,end-mid)
